export const logger = {
  log(level: string, message: any, error?: any) {
    const timestamp = new Date().toISOString();
    const stack = error ? error.stack : '';
    const formattedMessage = `[${timestamp}] [${level}] ${message} ${stack}`;
    switch (level) {
      case 'DEBUG': {
        console.debug(formattedMessage);
        break;
      }
      case 'ERROR':
      case 'FATAL': {
        console.error(formattedMessage);
        break;
      }
      case 'INFO': {
        console.info(formattedMessage);
        break;
      }
      case 'WARN': {
        console.warn(formattedMessage);
        break;
      }
      default: {
        console.log(formattedMessage);
      }
    }
  },
  debug(message: any) {
    this.log('DEBUG', message);
  },
  info(message: any) {
    this.log('INFO', message);
  },
  warn(message: any) {
    this.log('WARN', message);
  },
  error(message: any, error: any) {
    this.log('ERROR', message, error);
  },
  fatal(message: any, error: any) {
    this.log('FATAL', message, error);
  },
};
